package com.gitee.xmhzzz.device.service.domain;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @ClassName DeviceEntity
 * @Description
 * @Author wzq
 * @Date 2024/5/23 19:51
 * @Version 1.0
 */
@Data
@Schema(description = "设备实体")
public class DeviceEntity extends BaseInfo{

    @Schema(description = "id")
    private Long id;

    @Schema(description = "设备key")
    private String deviceKey;

    @Schema(description = "产品key")
    private String productKey;

    @Schema(description = "设备名称")
    private String deviceName;

    @Schema(description = "激活时间")
    private LocalDateTime activationTime;

    @Schema(description = "最后上线时间")
    private LocalDateTime lastOnlineTime;

    @Schema(description = "在线状态")
    private Integer online;

    @Schema(description = "状态，1启用，0禁用")
    private Integer state;

    @Schema(description = "产品说明")
    private String  desc;

    @Schema(description = "连接信息")
    private ConnectInfo connectInfo;

    @Schema(description = "客户端信息")
    private ClientInfo clientInfo;

    @Schema(description = "设备扩展信息")
    private DeviceExpand deviceExpand;

    @Schema(description = "设备属性信息")
    private Map<String,Property> property;

    @Schema(description = "设备标签信息")
    private DeviceTag deviceTag;


    @Data
    @Schema(description = "客户端信息值对象")
    public static class ClientInfo{

        //客户端列举ip
        @Schema(description = "客户端信息值对象")
        private String clientId;

        //协议
        @Schema(description = "客户端信息值对象")
        private String protocol;

        //版本
        @Schema(description = "客户端信息值对象")
        private String version;

        //ip地址
        @Schema(description = "客户端信息值对象")
        private String ipaddress;

        //名称
        @Schema(description = "客户端信息值对象")
        private String username;
    }

    @Data
    @Schema(description = "连接信息值对象")
    public static class ConnectInfo{

        @Schema(description = "协议")
        private String protocol;

        @Schema(description = "版本")
        private String version;

        @Schema(description = "域名")
        private String address;

        @Schema(description = "端口")
        private String port;

        @Schema(description = "产品key")
        private String productKey;

        @Schema(description = "设备key")
        private String deviceKey;

        @Schema(description = "设备key秘钥")
        private String deviceSecret;
    }

    @Data
    @Schema(description = "设备扩展信息值对象")
    public static class DeviceExpand{

        @Schema(description = "sdk")
        private String sdk;

        @Schema(description = "sdk版本")
        private String sdkVersion;

        @Schema(description = "模组工厂")
        private String moduleFactory;

        @Schema(description = "模组信息")
        private Map<String,Object> moduleInfo;

    }

    @Data
    @Schema(description = "设备扩展信息值对象")
    public static class Property{

        @Schema(description = "属性名")
        private String name;

        @Schema(description = "属性值")
        private String value;

        @Schema(description = "子属性值")
        private Map<String,Property> property;
    }


    @Data
    @Schema(description = "设备标签信息值对象")
    public static class DeviceTag {

        @Schema(description = "标签名称")
        private String name;

        @Schema(description = "标签值")
        private String value;

        @Schema(description = "类型", defaultValue = "string")
        private String type;

        @Schema(description = "说明")
        private String description;

        // private DataType dataType;
    }

}
